//
//  DingERedViewController.m
//  XiangCaoJiaYuan
//
//  Created by tongj on 2017/8/25.
//  Copyright © 2017年 tongj. All rights reserved.
//

#import "DingERedViewController.h"
#import "UIButton+LT.h"
@interface DingERedViewController ()<UITextFieldDelegate>
{
    UIView* ShareView;
    UIView* ShareView2;
    UILabel *money;
    UILabel *money2;

    UIImageView *yue;
    UIImageView *weixin;
    UIImageView *zhifubao;
    NSString *statusMoney;
    UIImageView *moneyImage;
    UILabel *l6;
}
@property (weak, nonatomic) IBOutlet UITextField *Ding;
@property (weak, nonatomic) IBOutlet UITextField *Count;
@property (weak, nonatomic) IBOutlet UITextView *Zhufu;
- (IBAction)Click:(id)sender;

@end

@implementation DingERedViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title =@"定额红包";
    [UIButton backButton:self.navigationItem Col:self];
    if ([_status isEqualToString:@"1"]) {
        _Ding.placeholder = @"单个红包金额不低于0.03元";
        
    }else{
        _Ding.placeholder = @"单个红包金额不低于0.1元";
        
    }
    [self view1];
    [self view2];
    // Do any additional setup after loading the view from its nib.
}
-(void)back{
    
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(void)view1{
    statusMoney = @"1";
    ShareView = [[UIView alloc]initWithFrame:CGRectMake(0, 0,UIScreen_WIDTH,UIScreen_HEIGHT)];
    ShareView.backgroundColor = UIColorFromRGBA(0x000000, 0.8);
    ShareView.hidden = YES;
    [[UIApplication sharedApplication].keyWindow addSubview:ShareView];
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, UIScreen_HEIGHT-330, UIScreen_WIDTH,  330)];
    view.backgroundColor = [UIColor whiteColor];
    [ShareView addSubview:view];
    UILabel *lan = [[UILabel alloc]initWithFrame:CGRectMake(UIScreen_WIDTH/2-60, 15, 120, 20)];
    lan.text = @"选择支付方式";
    [view addSubview:lan];
    UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(10, 15, 20, 20)];
    [button setImage:[UIImage imageNamed:@"错误"] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(clickcha) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:button];
    UIButton *yue1 = [[UIButton alloc]initWithFrame:CGRectMake(0, 50, UIScreen_WIDTH, 40)];
    [yue1 addTarget:self action:@selector(click1) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:yue1];
    yue = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 20, 20)];
    yue.image = [UIImage imageNamed:@"选择支付方式(1)"];
    [yue1 addSubview:yue];
    UIImageView *imag1 = [[UIImageView alloc]initWithFrame:CGRectMake(40, 10, 20, 20)];
    imag1.image = [UIImage imageNamed:@"香草邦_18--@2x"];
    [yue1 addSubview:imag1];
    UILabel *l1 = [[UILabel alloc]initWithFrame:CGRectMake(70, 10, 70, 20)];
    l1.text = @"余额支付";
    l1.font = [UIFont systemFontOfSize:15];
    [yue1 addSubview:l1];
    UILabel *line1 = [[UILabel alloc]initWithFrame:CGRectMake(0, 95, UIScreen_WIDTH, 1)];
    line1.backgroundColor= UIColorFromRGBA(0xc0c0c0, 0.8);
    [view addSubview:line1];
    
    UIButton *weixin1 = [[UIButton alloc]initWithFrame:CGRectMake(0, 100, UIScreen_WIDTH, 40)];
    [weixin1 addTarget:self action:@selector(click2) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:weixin1];
    weixin = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 20, 20)];
    weixin.image = [UIImage imageNamed:@"未打钩"];
    [weixin1 addSubview:weixin];
    UIImageView *imag2 = [[UIImageView alloc]initWithFrame:CGRectMake(40, 10, 20, 20)];
    imag2.image = [UIImage imageNamed:@"微信"];
    [weixin1 addSubview:imag2];
    UILabel *line2 = [[UILabel alloc]initWithFrame:CGRectMake(0, 145, UIScreen_WIDTH, 1)];
    line2.backgroundColor= UIColorFromRGBA(0xc0c0c0, 0.8);
    [view addSubview:line2];
    UILabel *l2 = [[UILabel alloc]initWithFrame:CGRectMake(70, 110, 80, 20)];
    l2.text = @"微信支付";
    l2.font = [UIFont systemFontOfSize:15];
    [view addSubview:l2];
    
    UIButton *zhifubao1 = [[UIButton alloc]initWithFrame:CGRectMake(0, 150, UIScreen_WIDTH, 40)];
    [zhifubao1 addTarget:self action:@selector(click3) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:zhifubao1];
    UIImageView *imag3 = [[UIImageView alloc]initWithFrame:CGRectMake(40, 10, 20, 20)];
    imag3.image = [UIImage imageNamed:@"支付宝"];
    [zhifubao1 addSubview:imag3];
    UILabel *l3 = [[UILabel alloc]initWithFrame:CGRectMake(70, 10, 90, 20)];
    l3.text = @"支付宝支付";
    l3.font = [UIFont systemFontOfSize:15];
    [zhifubao1 addSubview:l3];
    zhifubao = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 20, 20)];
    zhifubao.image = [UIImage imageNamed:@"未打钩"];
    [zhifubao1 addSubview:zhifubao];
    
    UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(0, 190, UIScreen_WIDTH, 40)];
    view1.backgroundColor = UIColorFromRGBA(0xc0c0c0, 0.8);
    [view addSubview:view1];
    
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(UIScreen_WIDTH/2-30, 245, 30, 20)];
    label.text = @"支付";
    label.font = [UIFont systemFontOfSize:14];
    [view addSubview:label];

    money = [[UILabel alloc]initWithFrame:CGRectMake(UIScreen_WIDTH/2+5, 245, 150, 20)];
//    money.text = [NSString stringWithFormat:@"￥%@"];
    money.textColor = colordg;
    money.font = [UIFont systemFontOfSize:19];
    [view addSubview:money];
    
    UIButton *sure = [[UIButton alloc]initWithFrame:CGRectMake(20, 280, UIScreen_WIDTH-40, 40)];
    [sure setImage:[UIImage imageNamed:@"支付宝支付-选择支付方式"] forState:UIControlStateNormal];
    [sure addTarget:self action:@selector(clicksure) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:sure];
    
}
-(void)view2{
    ShareView2 = [[UIView alloc]initWithFrame:CGRectMake(0, 0,UIScreen_WIDTH,UIScreen_HEIGHT)];
    ShareView2.backgroundColor = UIColorFromRGBA(0x000000, 0.8);
    ShareView2.hidden = YES;
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, UIScreen_HEIGHT-330, UIScreen_WIDTH,  330)];
    view.backgroundColor = [UIColor whiteColor];
    [ShareView2 addSubview:view];

    [[UIApplication sharedApplication].keyWindow addSubview:ShareView2];
    UILabel *lan = [[UILabel alloc]initWithFrame:CGRectMake(UIScreen_WIDTH/2-35, 15, 70, 20)];
    lan.text = @"确认付款";
    [view addSubview:lan];
    UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(10, 15, 20, 20)];
    [button setImage:[UIImage imageNamed:@"错误"] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(clickcha2) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:button];
    
    UILabel *l1 = [[UILabel alloc]initWithFrame:CGRectMake(10, 60, 80, 20)];
    l1.text = @"收款方";
    l1.textColor = coloreg2;
    l1.font = [UIFont systemFontOfSize:15];
    [view addSubview:l1];
    UILabel *l2 = [[UILabel alloc]initWithFrame:CGRectMake(10, 110, 80, 20)];
    l2.text = @"订单信息";
    l2.textColor = coloreg2;
    l2.font = [UIFont systemFontOfSize:15];
    [view addSubview:l2];
    UILabel *l3 = [[UILabel alloc]initWithFrame:CGRectMake(10, 160, 80, 20)];
    l3.text = @"付款方式";
    l3.textColor = coloreg2;
    l3.font = [UIFont systemFontOfSize:15];
    [view addSubview:l3];
    UILabel *l4 = [[UILabel alloc]initWithFrame:CGRectMake(UIScreen_WIDTH-90, 60, 80, 20)];
    l4.text = @"和叶网络";
    l4.font = [UIFont systemFontOfSize:15];
    [view addSubview:l4];
    UILabel *l5 = [[UILabel alloc]initWithFrame:CGRectMake(UIScreen_WIDTH-90, 110, 80, 20)];
    l5.text = @"香草邦";
    l5.font = [UIFont systemFontOfSize:15];
    [view addSubview:l5];
    l6 = [[UILabel alloc]initWithFrame:CGRectMake(UIScreen_WIDTH-90, 160, 80, 20)];
    l6.textColor = coloreg2;
    l6.font = [UIFont systemFontOfSize:15];
    [view addSubview:l6];

    UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(0, 190, UIScreen_WIDTH, 40)];
    view1.backgroundColor = UIColorFromRGBA(0xc0c0c0, 0.8);
    [view addSubview:view1];
    
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(UIScreen_WIDTH/2-30, 245, 30, 20)];
    label.text = @"支付";
    label.font = [UIFont systemFontOfSize:14];
    [view addSubview:label];

    moneyImage = [[UIImageView alloc]initWithFrame:CGRectMake(UIScreen_WIDTH/2-65, 15, 20, 20)];
    [view addSubview:moneyImage];

    money2 = [[UILabel alloc]initWithFrame:CGRectMake(UIScreen_WIDTH/2+5, 245, 150, 20)];
    //    money.text = [NSString stringWithFormat:@"￥%@"];
    money2.textColor = colordg;
    money2.font = [UIFont systemFontOfSize:19];
    [view addSubview:money2];
    
    UIButton *sure = [[UIButton alloc]initWithFrame:CGRectMake(20, 280, UIScreen_WIDTH-40, 40)];
    [sure setImage:[UIImage imageNamed:@"支付宝支付-选择支付方式"] forState:UIControlStateNormal];
    [sure addTarget:self action:@selector(clicksure) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:sure];
    UILabel *line1 = [[UILabel alloc]initWithFrame:CGRectMake(0, 95, UIScreen_WIDTH, 1)];
    line1.backgroundColor= UIColorFromRGBA(0xc0c0c0, 0.8);
    [view addSubview:line1];
    UILabel *line2 = [[UILabel alloc]initWithFrame:CGRectMake(0, 145, UIScreen_WIDTH, 1)];
    line2.backgroundColor= UIColorFromRGBA(0xc0c0c0, 0.8);
    [view addSubview:line2];


    
}
-(void)clickcha
{
    ShareView.hidden = YES;
}
-(void)clickcha2
{
    ShareView2.hidden = YES;
}
-(void)click1{
    statusMoney = @"1";
    yue.image = [UIImage imageNamed:@"选择支付方式(1)"];
    weixin.image = [UIImage imageNamed:@"未打钩"];
    zhifubao.image = [UIImage imageNamed:@"未打钩"];




    
}-(void)click2{
    statusMoney = @"2";
    yue.image = [UIImage imageNamed:@"未打钩"];
    weixin.image = [UIImage imageNamed:@"选择支付方式(1)"];
    zhifubao.image = [UIImage imageNamed:@"未打钩"];

}-(void)click3{
    statusMoney = @"3";
    yue.image = [UIImage imageNamed:@"未打钩"];
    weixin.image = [UIImage imageNamed:@"未打钩"];
    zhifubao.image = [UIImage imageNamed:@"选择支付方式(1)"];

}
- (IBAction)Click:(id)sender {
    [self.view endEditing:YES];

   float floatString = [_Ding.text floatValue];
    int a = [_Count.text intValue];
    float float1 = a*floatString;
    if ([_status isEqualToString:@"1"]) {
        if (floatString > 0.029) {
            if (a>=100&&a<=200) {
                 ShareView.hidden = NO;
                money.text = [NSString stringWithFormat:@"￥%.2f",float1];

            }else{
                [self.view makeToast:@"红包个数不少于100个，不多于200个"];

            }
        }else{
            [self.view makeToast:@"单个红包金额不得小于0.03"];
        }
    }else{
        if (floatString > 0.099) {
            if (a>=100&&a<=200) {
                 ShareView.hidden = NO;
                money.text = [NSString stringWithFormat:@"￥%.2f",float1];

            }else{
                [self.view makeToast:@"红包个数不少于100个，不多于200个"];
                
            }
        }else{
            [self.view makeToast:@"单个红包金额不得小于0.1"];
        }
    }

}
-(void)clicksure
{
    ShareView.hidden = YES;
    ShareView2.hidden = NO;
    money2.text = [NSString stringWithFormat:@"%@",money.text];

    if ([statusMoney isEqualToString:@"1"]) {
        moneyImage.image = [UIImage imageNamed:@"香草邦_18--@2x"];
        l6.text = @"余额支付";
    }else if ([statusMoney isEqualToString:@"2"]){
        moneyImage.image = [UIImage imageNamed:@"微信"];
        l6.text = @"微信支付";
    }else{
        moneyImage.image = [UIImage imageNamed:@"支付宝"];
        l6.text = @"支付宝支付";
    }
}
@end
